﻿/***********************************************************************************************************************************
 *    Name: Job_Owner-sa.sql
 *  Author: Frank Figearo — http://www.sqlnerd.me/ — frank@sqlnerd.me
 * Summary: Generate script to change jobs' owner to sa.
**/
USE msdb;
SELECT tsql_command= N'EXECUTE dbo.sp_update_job @job_id= ''' + CAST(job_id AS sysname) + N''', @owner_login_name= ''sa'';	-- '+ name
  FROM dbo.sysjobs
  WHERE category_id = 0 AND owner_sid <> 0x01
  ORDER BY name;
GO